package ge.telasi.tasks.ui.log;

import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

/**
 * @author dimitri
 */
public class InlineLogger extends JPanel implements Logger {
    JTextArea msg = new JTextArea();

    public InlineLogger() {
        setBorder(null);
        setForeground(Color.RED);
        msg.setEditable(false);
        msg.setBorder(null);
        msg.setOpaque(false);
        msg.setWrapStyleWord(true);
        msg.setLineWrap(true);
        msg.setRows(2);
        msg.setForeground(Color.RED);
        msg.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        setLayout(new BorderLayout());
        JScrollPane scrl = new JScrollPane(msg);
        scrl.setOpaque(false);
        scrl.setBorder(null);
        setOpaque(false);
        setBorder(null);
        add(scrl);
    }

    public void clear() {
        msg.setText("");
    };

    public void showError(String error) {
        msg.setText(error);
        msg.setCaretPosition(0);
    }

}
